#%RAML 1.0
title: Group Service API for Bungarus
version: v1.0
baseUri: http://13.76.135.42/api/gs/v1.0/tenants/{tenantId}
baseUriParameters:
  tenantId:
    description: Unique id of the tenant
mediaType: application/json
protocols: [HTTP, HTTPS]
types:
  Member:
    type: object
    properties:
      id: integer
      accountName: string
      name: string
      tenantId: integer
  Error:
    type: object
    properties:
      message: string
      type: string
      code: integer
      error_subcode: string
      error_user_msg: string
      trance_id: string
  Group:
    type: object
    properties:
      name: string
      _id: integer
      tenantId: integer
  PagePayload_Group:
    type: object
    properties:
      total: integer
      page: integer
      size: integer
      contents: Group[]
  PagePayload_Member:
    type: object
    properties:
      total: integer
      page: integer
      size: integer
      contents: Member[]

/members:
  description: API endpoints of member service
  post:
    description: Create a member belongs to the specific tenant
    headers:
      Content-Type:
        application/x-www-form-urlencoded
      X-BUNGARUS-TOKEN: string
    queryParameters:
      account:
        description: Account of user
        type: string
        required: true
        example: account1
      pwd:
        description: Password of account
        type: string
        required: true
        example: password1
    responses:
      200:
        headers:
          Content-Type:
            application/json;charset=UTF-8
        body:
          type: Member
          example: |
            {
                "accountName": "account9",
                "name": "name",
                "tenantId": 10000,
                "id": 547007166039388160
            }
      400:
        body:
          type: Error
          example: |
            {
                "message": "Failed to convert value of type 'java.lang.String' to required type 'long'; nested exception is java.lang.NumberFormatException: For input string: \"\"",
                "type": null,
                "code": 0,
                "error_subcode": null,
                "error_user_msg": null,
                "trace_id": null
            }

/groups:
  description: API endpoints of group service
  get:
    description: Retrieve the list of group the user is belongs to.
    headers:
      X-BUNGARUS-TOKEN: string
    queryParameters:
      mid:
        description: Unique id of user
        type: integer
        required: true
        example: 1001
      offset:
        description: the start poisition of the list of group
        type: integer
        required: true
        example: 0
      size:
        description: the number of group list per page
        type: integer
        required: true
        example: 20
        minimum: 1
    responses:
      200:
        body:
          type: PagePayload_Group
      400:
        body:
          type: Error

  post:
    description: Create a group.
    headers:
      Content-Type:
        application/x-www-form-urlencoded
      X-BUNGARUS-TOKEN: string
    queryParameters:
      id:
        description: Unique id of group
        type: integer
        required: true
      name:
        description: Name of group
        type: string
        required: true
    responses:
      200:
        body:
          type: Group
      400:
        body:
          type: Error

/groups/{groupId}/members:
  description: API endpoints of group service to manage member
  uriParameters:
    groupId:
      description: Unique id of the group
  get:
    description: Retrieve the list of member belongs to the specific group
    headers:
      X-BUNGARUS-TOKEN: string
    queryParameters:
      offset:
        description: the start point of member list
        type: integer
        required: true
      size:
        description: the count of members per page
        type: integer
        required: true
    responses:
      200:
        body:
          type: PagePayload_Member
      400:
        body:
          type: Error

  post:
    description: Add the specific memeber into the group
    headers:
      Content-Type:
        application/x-www-form-urlencoded
      X-BUNGARUS-TOKEN: string
    queryParameters:
      id:
        description: Unique id of user
        type: integer
        required: true
      name:
        description: Name of user
        type: string
        required: true
      account:
        description: Account of user
        type: string
        required: true
    responses:
      200:
        body:
          type: Member
      400:
        body:
          type: Error
